﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Nancy.Model.DataModel;

namespace Nancy.Repository.BaseRepository
{
    public interface IBaseRepository<T> where T : BaseEntity
    {
        /// <summary>
        /// 根据ID 得到一个对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T GetById(Guid id);


        /// <summary>
        /// 获取全部
        /// </summary>
        /// <returns></returns>
        List<T> GetAll();

        /// <summary>
        /// 根据条件获取数据
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        List<T> GetList(Expression<Func<T, bool>> criteria);

        /// <summary>
        /// 添加一个对象
        /// </summary>
        /// <param name="entity"></param>
        void Add(T entity);

        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entityList"></param>
        void AddBatch(List<T> entityList);

        /// <summary>
        /// 单个更新
        /// </summary>
        /// <param name="entity"></param>
        void Update(T entity);

        /// <summary>
        /// 批量更新 
        /// </summary>
        /// <param name="entityList"></param>
        void UpdateBatch(List<T> entityList);
        
        /// <summary>
        /// 根据ID删除
        /// </summary>
        /// <param name="id"></param>
        void DeleteById(Guid id);

        /// <summary>
        /// 根据实体删除
        /// </summary>
        /// <param name="entity"></param>
        void Delete(T entity);

        /// <summary>
        /// 根据条件删除
        /// </summary>
        /// <param name="criteria"></param>
        void Delete(Expression<Func<T, bool>> criteria);

        /// <summary>
        /// 得到一个IQueryable 查询对象
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetQueryable();


    }
}
